﻿Public Class frmDangNhap
    Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDangNhap.Click
        Dim bus As New DangNhapBUS
        If txtMatKhau.Text = "" Or txtTenDN.Text = "" Then
            MsgBox("Tên đăng nhập hoặc mật khẩu không được để trống", MsgBoxStyle.Information, "Thông báo")
            txtTenDN.Focus()
            Return
        End If
        If bus.DangNhap(txtTenDN.Text, txtMatKhau.Text) = 1 Then
            frmMain.lbTrangThaiDangNhap.Text = "Xin chào " + txtTenDN.Text
            frmMain.MenuStrip1.Items(1).Enabled = True
            frmMain.MenuStrip1.Items(2).Enabled = True
            frmMain.MenuStrip1.Items(3).Enabled = True
            frmMain.MenuStrip1.Items(4).Enabled = True
            frmMain.HệThốngToolStripMenuItem.DropDownItems.Item(0).Enabled = False
            frmMain.HệThốngToolStripMenuItem.DropDownItems.Item(1).Enabled = True
            frmMain.HệThốngToolStripMenuItem.DropDownItems.Item(2).Enabled = True

            'gan ten dang nhap vs mat khau vao bien strUN va strMK cua ham frmMain
            frmMain.strUN = txtTenDN.Text
            frmMain.strMK = txtMatKhau.Text
            Me.Close()
        Else
            txtTenDN.Focus()
        End If

    End Sub

    Private Sub frmDangNhap_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub

    Private Sub btnHuyBo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnHuyBo.Click
        Me.Close()
    End Sub
End Class